//
//  UIView+Extension.swift
//  DLuxTravel
//
//  Created by 陆涛 on 2018/11/22.
//  Copyright © 2018 imguider. All rights reserved.
//

import UIKit

enum ShadowType {
    case home
    case hotel
    case hotelDetail
}

extension UIView {
    
    
    func addShadow(_ type:ShadowType) {
        
        switch type {
        case .home:
            
            let color = kTitleColor.withAlphaComponent(0.08)
            let offset = CGSize(width: 0, height: 2)
            
            addShadow(color: color, offset: offset, radius: 4)
        case .hotel:
            
            let color = UIColor.hexStringToColor(hexString: "#000000").withAlphaComponent(0.11)
            let offset = CGSize(width: 0, height: 2)
            
            addShadow(color: color, offset: offset, radius: 4)
        case .hotelDetail:
            
            let color = UIColor.hexStringToColor(hexString: "#020202").withAlphaComponent(0.18)
            let offset = CGSize(width: 0, height: 1.7)
            
            addShadow(color: color, offset: offset, radius: 1.7)
        }
    }
    
    private func addShadow(color:UIColor,offset:CGSize,radius:CGFloat) {
        
        self.layer.shadowOpacity = 1
        self.layer.shadowRadius = radius
        self.layer.shadowColor = color.cgColor
        self.layer.masksToBounds = false
        self.layer.shadowOffset = offset
    }
}
